<!DOCTYPE html><html lang="zh-CN"><head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>moment(Object) | Moment.js &#x6587;&#x6863;</title>
  <link rel="stylesheet" href="static/css/style.css">
  <link rel="shortcut icon" href="http://momentjs.cn/static/img/moment-favicon.png">
  <link rel="stylesheet" href="static/css/atom-one-light.min.css">
</head>
<body class="is-moment">
  <div class="hero hero-oneline">
    <div class="hero-centered">
      <h1>moment(Object)</h1>
    </div>
  </div>
  <div id="api-section-__FILENAME__">
    <div id="content" class="clearfix">
  
      <div id="column1" data-id="__ID__" class="interior">
        <header>
          <!-- <h1>moment(Object)</h1> -->
          <div id="gtoc">
            <ul>
              <!-- <li>v</li> -->
              <li>
                <a href="index.html#/parsing/object/" name="toc">&#x8FD4;&#x56DE;&#x4E0A;&#x5C42;&#x6587;&#x6863;</a>
              </li>
              <li style="border: none;">
                <a href="javascript:window.open('https://github.com/momentjscn/moment-docs-cn/edit/master/moment/01-parsing/06-object.md');" rel="nofollow" target="_blank">&#x63D0;&#x4EA4;&#x4FEE;&#x6539;</a>
              </li>
              <!-- <li>
                <a href="/search__SEARCH_PARAM__" name="toc">搜索</a>
              </li> -->
            </ul>
          </div>
          <hr>
        </header>

        <div id="biz_item"></div>
  
        <div id="apicontent">
          <div id="content_left">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment({unit: value, ...});
</code></pre>

							</div>
<pre><code class="language-javascript">moment({ hour:15, minute:10 });
moment({ y    :2010, M     :3, d   :5, h    :15, m      :10, s      :3, ms          :123});
moment({ year :2010, month :3, day :5, hour :15, minute :10, second :3, millisecond :123});
moment({ years:2010, months:3, days:5, hours:15, minutes:10, seconds:3, milliseconds:123});
moment({ years:2010, months:3, date:5, hours:15, minutes:10, seconds:3, milliseconds:123});
moment({ years:&apos;2010&apos;, months:&apos;3&apos;, date:&apos;5&apos;, hours:&apos;15&apos;, minutes:&apos;10&apos;, seconds:&apos;3&apos;, milliseconds:&apos;123&apos;});  // &#x4ECE; 2.11.0 &#x5F00;&#x59CB;&#x3002;
</code></pre>
<p>&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x6307;&#x5B9A;&#x5BF9;&#x8C61;&#x4E2D;&#x7684;&#x67D0;&#x4E9B;&#x5355;&#x4F4D;&#x6765;&#x521B;&#x5EFA; moment&#x3002;</p>
<p>&#x7701;&#x7565;&#x7684;&#x5355;&#x4F4D;&#x9ED8;&#x8BA4;&#x4E3A; 0 &#x6216;&#x5F53;&#x524D;&#x7684;&#x65E5;&#x671F;&#x3001;&#x6708;&#x4EFD;&#x548C;&#x5E74;&#x4EFD;&#x3002;</p>
<p><code>day</code> &#x548C; <code>date</code> &#x952E;&#x5747;&#x8868;&#x793A;&#x6708;&#x4EFD;&#x7684;&#x67D0;&#x5929;&#x3002;</p>
<p><code>date</code> &#x65B0;&#x589E;&#x4E8E; <strong>2.8.4</strong>&#x3002;</p>
<p>&#x4ECE; <strong>2.11.0</strong> &#x7248;&#x672C;&#x5F00;&#x59CB;&#xFF0C;&#x652F;&#x6301;&#x5B57;&#x7B26;&#x4E32;&#x503C;&#xFF08;&#x5982;&#x6700;&#x540E;&#x4E00;&#x884C;&#x793A;&#x4F8B;&#x6240;&#x793A;&#xFF09;&#x3002;</p>
<p>&#x6CE8;&#x610F;&#xFF0C;&#x50CF; <code>moment(Array)</code> &#x548C; <code>new Date(year, month, date)</code> &#x4E00;&#x6837;&#xFF0C;&#x6708;&#x4EFD;&#x4ECE; 0 &#x5F00;&#x59CB;&#x7D22;&#x5F15;&#x3002;</p>
					</div>
          <div id="content_right">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment({unit: value, ...});
</code></pre>

							</div>
<pre><code class="language-javascript">moment({ hour:15, minute:10 });
moment({ y    :2010, M     :3, d   :5, h    :15, m      :10, s      :3, ms          :123});
moment({ year :2010, month :3, day :5, hour :15, minute :10, second :3, millisecond :123});
moment({ years:2010, months:3, days:5, hours:15, minutes:10, seconds:3, milliseconds:123});
moment({ years:2010, months:3, date:5, hours:15, minutes:10, seconds:3, milliseconds:123});
moment({ years:&apos;2010&apos;, months:&apos;3&apos;, date:&apos;5&apos;, hours:&apos;15&apos;, minutes:&apos;10&apos;, seconds:&apos;3&apos;, milliseconds:&apos;123&apos;});  // from 2.11.0
</code></pre>
<p>You can create a moment by specifying some of the units in an object.</p>
<p>Omitted units default to 0 or the current date, month, and year.</p>
<p><code>day</code> and <code>date</code> key both mean day-of-the-month.</p>
<p><code>date</code> was added in <strong>2.8.4</strong>.</p>
<p>String values (as shown on the last line) are supported from version
<strong>2.11.0</strong>.</p>
<p>Note that like <code>moment(Array)</code> and <code>new Date(year, month, date)</code>, months are 0 indexed.</p>
					</div>
          <div></div>
        </div>
      </div>
    </div>
  </div>
  
  <script src="static/js/highlight.min.js"></script>
  <script src="static/js/javascript.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
  <script>var _hmt = _hmt || []; (function () { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?7a7f78c805fbacc7e075d34f153031aa"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();</script>

  <style>
    .hero-centered {
      margin: 0;
          margin-left: 10px;
    }
#gtoc ul {
  list-style: none;
  margin-left: 0;
  line-height: 1.5rem;
  padding: 0;
}
#gtoc>ul>li {
  display: inline;
  border-right: 1px solid #000;
  margin-right: .4rem;
  padding-right: .4rem;
}
#gtoc>ul>li>a {
  color: #61b2a7;
}
#content_left {
  width: 49%;float: left;border-right: 1px solid #eee;    padding-right: 2%;
}
#content_right {
float: left;width: 48%;margin-left: 3%;
}
#column1 {
  padding: 0 2rem;
}
  </style>


</body></html>